<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <title>投票报名</title>
    <link rel="stylesheet" href="__PUBLIC__/css/weui/weui.min.css">
    <link rel="stylesheet" href="//at.alicdn.com/t/font_i2wdwdlpsmrt3xr.css">
    <link rel="stylesheet" href="__PUBLIC__/seller/css/weui.css">
    <link rel="stylesheet" href="__PUBLIC__/seller/css/weui2.css">
    <style>
        body{margin:0;padding:0;}
        p{
            padding: 0;
            margin:0;
        }
        a,a:hover{
            text-decoration: none
        }
        li{
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .row{
            margin-top: 15px;
            margin-left:10px;
            margin-right:10px;
           
        }
        .container{
            position: absolute;
            top: 0;
            bottom: 0;
            margin-bottom: 50px;
            overflow-y: scroll;
            -webkit-overflow-scrolling: touch;
        }
        .container .vote_baoming .weui-cells{
            background: transparent;
        }
       

        .container .vote_info .info_bt{
            position: relative;
            text-align: center;
        }
        .container .vote_info .info_bt div{
            font-size:16px;
            color:#fff;
            border:1px solid #FF7E4D;
            border-radius: 5px;
            display:inline-block;

        }
        .container .vote_info .info_bt div b{
            font-size:16px;
            color:#fff;
            background: #FF7E4D;
            padding: 0;
            margin: 0;
            height: 100%;
            width:20px;
            display: inline-block;
        }
        .container .vote_info .info_bt div span{
            color:#333;
            padding: 0px 5px;
            font-weight: bold;
        }


        .index_text{
            text-align: center;
            font-size:18px;
            font-family: "Microsoft YaHei" ;
            color:#666;
        }
        .gallery{display: none;}
    </style>
</head>
<body>
<div class="container" style="background:#fcf0f2">
    <div class="headpic">
      <div><img src="{$vote.fvote_picurl}" width="100%"></div>
    </div>
    <div class="row vote_baoming">
        <div class="weui-cells weui-cells_form">
           <form>
                <input type="hidden" name="voteid" value="{$voteid}"/>
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <div class="weui-uploader">
                                <div class="weui-uploader__hd">
                                    <p class="weui-uploader__title">图片上传</p>
                                    <div class="weui-uploader__info">0/3</div>
                                </div>
                                <div class="weui-uploader__box">
                                    <div class="weui-uploader__input-box"></div>
                                    <div class="weui-uploader__input-box"></div>
                                    <div class="weui-uploader__input-box"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                     <p class="weui_media_desc"><i class="weui_icon_info"></i><span style="font-size:12px;color:#F76260">1.亲，只有关注并注册会员才能报名。<br/>
                     <i class="weui_icon_info"></i>2.亲，参与活动前请确保穿着第七感觉品牌服饰拍照，否则审核不通过哦！</span></p>
                    <div class="weui-cells__title">参赛宣言</div>
                     <div class="weui-cell">
                            <div class="weui-cell__bd">
                                <textarea class="weui-textarea" name="item_xuanyan" placeholder="在这里可以为自己拉拉票哦！(少于100字)" rows="3"></textarea>
                                <div class="weui-textarea-counter"><span>0</span>/200</div>
                            </div>
                     </div>
                     <button type="button" class="weui-btn weui-btn_primary subbtn" style="background:#ff8ca3">确认报名</button>
                     <a href="{:U('Interact/vote_view',array('voteid'=>$voteid,'moban'=>$moban,'ccdaven'=>$ccdaven))}" class="weui-btn weui-btn_primary" style="background:#ff8ca3">返回首页</a>
                </form>
                </div>
     
    </div>
    <div class="row vote_info">
        <!-- 内容一 -->
        <div class="info_bt">
            <notempty name="vote['fvote_info_bt1']"><div><b>◆</b><span>{$vote.fvote_info_bt1}</span><b>◆</b></div></notempty>
        </div>
        <div class="info_cont">
          {$vote.fvote_info_cont1|htmlspecialchars_decode=###}
        </div>
        <!-- 内容二 -->
        <div class="info_bt">
            <notempty name="vote['fvote_info_bt2']"><div><b>◆</b><span>{$vote.fvote_info_bt2}</span><b>◆</b></div></notempty>
        </div>
        <div class="info_cont">
          {$vote.fvote_info_cont2|htmlspecialchars_decode=###}
        </div>
        <!-- 内容三 -->
      <!--   <div class="info_bt">
            <notempty name="vote['fvote_info_bt3']"><div><b>◆</b><span>{$vote.fvote_info_bt3}</span><b>◆</b></div></notempty>
        </div>
        <div class="info_cont">
          {$vote.fvote_info_cont3|htmlspecialchars_decode=###}
        </div> -->
    </div>
    
</div>
<!-- 包含通用菜单栏 -->
<include file="foot_nav" />
</body>
<script src="__PUBLIC__/seller/js/weui_zepto.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<!-- <script src="__PUBLIC__/js/vconsole.min.js"></script> -->
<script>
//底部菜单规格按钮弹出层
$(function(){
            var $androidActionSheet = $('#androidActionsheet');
            var $androidMask = $androidActionSheet.find('.weui-mask');
            var $sure_btn = $androidActionSheet.find('.sure_btn');

            $("#showAndroidActionSheet").on('click', function(){
                $androidActionSheet.fadeIn(200);
                $androidMask.on('click',function () {
                    $androidActionSheet.fadeOut(200);
                });
                $sure_btn.on('click',function () {
                    $androidActionSheet.fadeOut(200);
                });
            });
        });
wx.config({
    debug: false,
    appId: '{$signPackage["appId"]}',
    timestamp: '{$signPackage["timestamp"]}',
    nonceStr: '{$signPackage["nonceStr"]}',
    signature: '{$signPackage["signature"]}',
    jsApiList: [
      'chooseImage', 'uploadImage', 'downloadImage'
    ]
  });
  

    $('.subbtn').click(function(){
        var data=$('form').serializeArray();
        var datastr=JSON.stringify(data);
        if(datastr.indexOf('wxpic')==-1){
            $.toast('请上传至少一张图片','forbidden');
            return false;
        }
        $.post('{:U("Ajax/insert_votebaoming")}',data,function(res){
            if(res.error=="no_subsribe"){
                $.confirm(res.msg, "温馨提示", function() {
                     gosubscribe();
                }, function() {
                  //取消操作
                }); 
            }else if(res.error=="no_reg"){
                $.confirm(res.msg, "温馨提示", function() {
                     location.href='{:U("Home/Register/index")}';
                }, function() {
                  //取消操作
                }); 
            }else{
                $.toast(res.msg,res.statu);
            }
           
            if(res.statu=="success"){
                setTimeout(function(){
                    location.href="{:U('Interact/vote_view',array('moban'=>$moban,'voteid'=>$voteid))}"
                },1000)
                
            }
        })
        //alert(JSON.stringify(data))
    })
    $('.weui-uploader__box').on('click','.weui-uploader__input-box',function(){
        var $this=$(this);
        $.confirm("参与评选前请确保穿着第七感觉品牌服饰拍照!", "温馨提示", function(){
                  //拍照或从手机相册中选图接口  
                          wx.chooseImage({  
                              count: 1,  
                              needResult: 1,  
                              sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有  
                              sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有  
                              success: function (res) {  
                                  var localId = res.localIds[0].toString(); // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片  
                                  wxuploadImage(localId,$this);
                              },  
                              fail: function (res) {  
                                  alterShowMessage("操作提示", JSON.stringify(res), "1", "确定", "", "", "");  
                              }  
                  
                          });  

                }, function() {
                  //取消操作
                });
        
             
    })

    /*获取关注链接跳转*/
    function gosubscribe(){
      $.post('{:U("Ajax/getwxsubscribeurl")}',{cc:'{$cc}'},function(data){
        if(data.statu=="success"){
           location.href=data.value;
        }
      })
    }
    //上传图片接口  
        function wxuploadImage(e,t) {  
             
            wx.uploadImage({  
                localId: e, // 需要上传的图片的本地ID，由chooseImage接口获得  
                isShowProgressTips: 1, // 默认为1，显示进度提示  
                success: function (res) {  
                    mediaId = res.serverId; // 返回图片的服务器端ID  
                        $.post('{:U("Ajax/getwxpic")}',{media_id:mediaId},function(data){
                               if(data=='fail'){
                                    var htmlstr='<li class="weui-uploader__file weui-uploader__file_status" style="background-image:url(Public/img/pic_160.jpg)"><div class="weui-uploader__file-content"><i class="weui-icon-warn"></i></div></li>'; 
                                    t.html(htmlstr);
                               }else{
                                    var htmlstr='<li class="weui-uploader__file" style="background-image:url('+e+')"></li><input type="hidden" name="wxpic[]" value="'+data+'"/>'; 
                                    t.attr('class','weui-uploader__file');
                                    t.html(htmlstr);
                                    view_img(e);
                               }

                            })
                        
                },  
                fail: function (error) {  
                    picPath = '';  
                    localIds = '';  
                    alert(Json.stringify(error));  
                }  
    
            });  
        }  
    //预览图片
    function view_img(src){
        $('.weui-uploader__file').click(function(){
            var $this=$(this);
            var htmlstr='<div class="page gallery js_show"><div class="page__hd"><h1 class="page__title">Gallery</h1><p class="page__desc">画廊，可实现上传图片的展示或幻灯片播放</p></div><div class="weui-gallery" style="display: block"><span class="weui-gallery__img" style="background-image: url('+src+');"></span><div class="weui-gallery__opr"><a href="javascript:" class="weui-gallery__del"><i class="weui-icon-delete weui-icon_gallery-delete"></i></a></div></div></div>';
            $('body').append(htmlstr);
            $gallery=$(".gallery");
            $gallery.fadeIn(100);
            $('.weui-gallery__img').click(function(){
                $gallery.fadeOut(100);
            })
            del_img($this);

        })
    }
    //删除图片
    function del_img(t){
         $('.weui-gallery__del').on('click',function(){
                $gallery.fadeOut(100);
                t.attr('class','weui-uploader__input-box');
                t.html('');
            })
    }
 

 
</script>

</html>